# 病历单类
# 包含属性：病历单号（10位），患者姓名，患者身份证号，患者年龄，患者性别，诊断说明，医师号，医生姓名，医生建议。
from domain.doctor import Doctor
from domain.patient import Patient


class MedicalRecord:
    def __init__(self,record_id: int, patient: Patient, doctor: Doctor, diagnosis: str, advice: str):
        self._record_id = record_id
        self._patient_card_id = patient.card_id
        self._patient_name = patient.name
        self._patient_age = patient.age
        self._patient_gender = patient.gender
        self._diagnosis = diagnosis
        self._doctor_name = doctor.name
        self._doctor_id = doctor.doctor_id
        self._advice = advice

    @property
    def record_id(self) -> int:
        """获取病历单号"""
        return self._record_id

    @record_id.setter
    def record_id(self, record_id: int):
        """设置病历单号"""
        if not isinstance(record_id, int):
            raise ValueError("病历单号必须是整数")
        self._record_id = record_id

    @property
    def patient_card_id(self) -> str:
        """获取患者身份证号"""
        return self._patient_card_id

    @patient_card_id.setter
    def patient_card_id(self, patient_card_id: str):
        """设置患者身份证号"""
        if not isinstance(patient_card_id, str):
            raise ValueError("患者身份证号必须是字符串")
        self._patient_card_id = patient_card_id

    @property
    def patient_name(self) -> str:
        """获取患者姓名"""
        return self._patient_name

    @patient_name.setter
    def patient_name(self, patient_name: str):
        """设置患者姓名"""
        if not isinstance(patient_name, str):
            raise ValueError("患者姓名必须是字符串")
        self._patient_name = patient_name

    @property
    def patient_age(self) -> str:
        """获取患者年龄"""
        return self._patient_age

    @patient_age.setter
    def patient_age(self, patient_age: int):
        """设置患者年龄"""
        if not isinstance(patient_age, int) or patient_age < 0:
            raise ValueError("患者年龄必须是非负整数")
        self._patient_age = patient_age

    @property
    def patient_gender(self) -> str:
        """获取患者性别"""
        return self._patient_gender

    @patient_gender.setter
    def patient_gender(self, patient_gender: str):
        """设置患者性别"""
        if not isinstance(patient_gender, str):
            raise ValueError("患者性别必须是字符串")
        self._patient_gender = patient_gender

    @property
    def diagnosis(self) -> str:
        """获取诊断说明"""
        return self._diagnosis

    @diagnosis.setter
    def diagnosis(self, diagnosis: str):
        """设置诊断说明"""
        if not isinstance(diagnosis, str):
            raise ValueError("诊断说明必须是字符串")
        self._diagnosis = diagnosis

    @property
    def doctor_name(self) -> str:
        """获取医生姓名"""
        return self._doctor_name

    @doctor_name.setter
    def doctor_name(self, doctor_name: str):
        """设置医生姓名"""
        if not isinstance(doctor_name, str):
            raise ValueError("医生姓名必须是字符串")
        self._doctor_name = doctor_name

    @property
    def doctor_id(self) -> str:
        """获取医生编号"""
        return self._doctor_id

    @doctor_id.setter
    def doctor_id(self, doctor_id: str):
        """设置医生编号"""
        if not isinstance(doctor_id, str):
            raise ValueError("医生编号必须是字符串")
        self._doctor_id = doctor_id

    @property
    def advice(self) -> str:
        """获取医生建议"""
        return self._advice

    @advice.setter
    def advice(self, advice: str):
        """设置医生建议"""
        if not isinstance(advice, str):
            raise ValueError("医生建议必须是字符串")
        self._advice = advice

    def get_info(self) -> str:
        """获取病历单信息的字符串表示"""
        return f"病历单号：{self._record_id}，患者姓名：{self._patient_name}，患者身份证号：{self._patient_card_id}，患者年龄：{self._patient_age}，患者性别：{self._patient_gender}，诊断说明：{self._diagnosis}，医师号：{self._doctor_id}，医生姓名：{self._doctor_name}，医生建议：{self._advice}"

    def print_info(self):
        """打印病历单信息"""
        print(
            f"病历单号：{self._record_id}，患者姓名：{self._patient_name}，患者身份证号：{self._patient_card_id}，患者年龄：{self._patient_age}，患者性别：{self._patient_gender}，诊断说明：{self._diagnosis}，医师号：{self._doctor_id}，医生姓名：{self._doctor_name}，医生建议：{self._advice}")

